<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>地址列表</title>
	<link href="${pageContext.request.contextPath }/client/css/main.css" rel="stylesheet" type="text/css" />
	<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css">
</head>
<body>
	<%@include file="./include/head.jsp" %>
	<%@include file="./include/menu_search.jsp" %>
	<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

	<div class="container" style="padding: 25px 0;">
		<c:if test="${addresses.size() == 0}">
			<div class="alert alert-danger" role="alert">您还没添加收货地址哦！</div>
		</c:if>
		<div class="clearfix" style="margin-bottom: 25px;">
			<a class="btn btn-primary pull-right" href="${pageContext.request.contextPath}/AddAddressServlet">添加新地址</a>
		</div>
		<table class="table table-bordered">
			<tr>
				<th>收件人姓名</th>
				<th>收件人电话</th>
				<th>收件人地址</th>
				<th>操作</th>
			</tr>
			<c:forEach items="${addresses}" var="address">
			   <tr>
			   		<td>${address.getName()}</td>
			   		<td>${address.getTelephone()}</td>
			   		<td>${address.getAddress()}</td>
			   		<td>
			   			<a class="btn btn-info" href="${pageContext.request.contextPath}/EditAddressServlet?id=${address.getId()}">编辑</a>
			   			<a class="btn btn-danger" href="${pageContext.request.contextPath}/DeleteAddressServlet?id=${address.getId()}">删除</a>
			   		</td>
			   </tr>
			</c:forEach>
		</table>
		<nav>
		  <ul class="pager">
		  	<c:if test="${hasPrev}">
		  		<li class="previous"><a href="${pageContext.request.contextPath}/AddressListServlet?page=${_page - 1}"><span aria-hidden="true">&larr;</span>上一页</a></li>
		  	</c:if>
		  	<c:if test="${hasNext}">
		    	<li class="next"><a href="${pageContext.request.contextPath}/AddressListServlet?page=${_page + 1}">下一页 <span aria-hidden="true">&rarr;</span></a></li>
		  	</c:if>
		  </ul>
		</nav>
	</div>
	
	<%@include file="./include/foot.jsp" %>
</body>
</html>